home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / wnos5src.zip / PUSHMAIL.C < prev    next >
Text File  |  1993-08-09  |  1KB  |  56 lines

  1. /* This program allows you to push mail destined for one host
  2.  * to another (i.e. going on vacation and shutting down your
  3.  * host but want your mail delivered by your "buddy"):
  4.  */
  5. #include <stdio.h>
  6. #include <dir.h>
  7. #include <dos.h>
  8. #include <fcntl.h>
  9. #include <string.h>
  10. #define MAXLINE 256
  11.  
  12. main(int argc,char *argv[])
  13. {
  14.     struct ffblk block;
  15.     int done,i;
  16.     FILE *fd,*fo;
  17.     char *j,str[MAXLINE+2],*strp;
  18.     
  19.     fprintf(stderr,"\n%s is COPYRIGHT 1989 by John D. Hays (KD7UW)\n",argv[0]);
  20.     fprintf(stderr,"Authorized for unlimited distribution for ");
  21.     fprintf(stderr,"Amateur Radio Use\n");
  22.     fprintf(stderr,"This notice must be retained.  All Rights Reserved.\n\n");
  23.     if (argc < 3)
  24.     {
  25.         fprintf(stderr,"Usage: %s oldhost forwardhost \007\n",argv[0]);
  26.         exit(0);
  27.     }
  28.     
  29.     done = findfirst("*.wrk",&block,0x3F);
  30.  
  31.     while (!done) {
  32.         if ((fd = fopen(block.ff_name,"r")) != NULL)
  33.         strp = str; /* Turbo-C is not handling fgets right ??? */
  34.         {
  35.             strp = fgets(strp,MAXLINE,fd);
  36.             j = strrchr(strp,'\n');
  37.             if (j != NULL) *j = '\0';
  38.             if (stricmp(argv[1],strp) == 0)
  39.             {
  40.                 fprintf(stderr,"Changing: %s\n",block.ff_name);
  41.                 i = unlink(block.ff_name);
  42.                 fo = fopen(block.ff_name,"w");
  43.                 fprintf(fo,"%s\n",argv[2]);
  44.                 while ((strp = fgets(strp,MAXLINE,fd)) != NULL)
  45.                 {
  46.                     fprintf(fo,"%s",strp);
  47.                 }
  48.             }
  49.             fclose(fd);
  50.             fclose(fo);
  51.         }
  52.         fprintf(stderr, "%s: Unable to open %s\n",argv[0],block.ff_name);
  53.         done = findnext(&block);
  54.     }
  55. }
  56.